﻿using Biz.Check;
using Biz.Status;
using Biz.Utility;
using DataLogical.TableClass;

namespace Biz
{
    public class PresentApplication : Application
    {
        private string intention;

        public string Intention
        {
            get { return intention; }
            set { intention = value; }
        }

        private string present = string.Empty;

        public string Present
        {
            get { return present; }
            set { present = value; }
        }
        private tblApplicationPresent application = new tblApplicationPresent();


        public override void save()
        {
            application.Applicant = ApplicantID.Value;
            application.Approver = ApproverID;
            application.GaUser = GaUser;
            application.ExcuteDate = ExcuteDate;
            application.Opposite = Opposite;
            application.CheckListType = CheckList.PRODUCT_NAME;
            CheckList.save();
            application.CheckListID = CheckList.Id;
            Status.save();
            application.Status = Status.PRODUCT_NAME;
            application.Remarks = Remarks;
            application.Present = Present;
            application.Intention = Intention;
            application.NumOfPerson = NumOfPerson;
            application.AverageAmount = AverageAmount;
            application.TotalAmount = TotalAmount;
            application.ActualFee = ActualFee;
            if (Id == Define.NEW)
                Id = application.Insert(application);
            else
                application.Update(application);
        }

        public override void load(int _id)
        {
            application = new tblApplicationPresent(_id);
            Id = application.ID;
            ApplicantID = application.Applicant;
            ApproverID = application.Approver;
            GaUser = application.GaUser;
            ExcuteDate = application.ExcuteDate.Value;
            Opposite = application.Opposite;
            CheckList = (CheckList)Factory.Factory.getInstance().CreateProduct(application.CheckListType);
            CheckList.load(application.CheckListID.Value);
            Status = (ApplicationStatus)Factory.Factory.getInstance().CreateProduct(application.Status);
            Remarks = application.Remarks;
            Present = application.Present ;
            Intention = application.Intention;
            NumOfPerson = application.NumOfPerson;
            AverageAmount = application.AverageAmount;
            TotalAmount = application.TotalAmount;
            ActualFee = application.ActualFee;
        }

        public override string PRODUCT_NAME
        {
            get { return ApplicationType.PRESENT.ToString(); }
        }
    }
}
